**Project: Strategic Discrimination**
**by Regina Bateson**
**Last modified: 21 June 2020**

//This do-file provides the output for the Study 2 results used to make Figures 2.1 and 2.2//

//First, the do-file cleans and re-organizes the dataset.//
//Then, the "Analysis" section provides the results for Figures 2.1 and 2.2.//
//Based on these results, I hand-drew Figures 2.1 and 2.2 using Adobe Illustrator.//

**GET THE DATASET**

//Download and save the file Study2.dta //
//It is part of this replication package // 

use "/Users/gina/Dropbox (Personal)/Strategic Discrimination resubmit/Perspectives Final Submission/Data and Replication Files/Study2.dta"

//Of course your version of the dataset is saved differently. Go open it.//

**CLEAN THE DATA AND SET UP VARIABLES**

**1. Create comparison groups**
//This is necessary in order to be able to compare each treatment group with the control group//

gen whitecompare=.
replace whitecompare=1 if treatment=="MediaAnalysis-WhiteVoters"
replace whitecompare=0 if treatment=="ControlConclusion"

gen stratcompare=.
replace stratcompare=1 if treatment=="StrategicThinkingTreatment"
replace stratcompare=0 if treatment=="ControlConclusion"

gen malecompare=.
replace malecompare=1 if treatment=="MediaAnalysis-MaleVoters"
replace malecompare=0 if treatment=="ControlConclusion"

**2. Create DVs **

//Start with WOMEN candidates//

replace warren=0 if warren==.
replace harris=0 if harris==.
replace buttigieg=0 if buttigieg==.
replace booker=0 if booker==.
replace klobuchar=0 if klobuchar==.
replace biden=0 if biden==.
replace sanders=0 if sanders==.
replace orourke=0 if orourke==.

//Top choice is a woman (binary)//

gen bestwoman1=0
replace bestwoman1=1 if warren==1
replace bestwoman1=1 if harris==1
replace bestwoman1=1 if klobuchar==1

//Total number of women in the top 3//
gen bestwarrentop3=0
replace bestwarrentop3=1 if warren>0
gen bestharristop3=0
replace bestharristop3=1 if harris>0
gen bestklobuchartop3=0
replace bestklobuchartop3=1 if klobuchar>0
gen bestwomantotal=bestwarrentop3+bestharristop3+bestklobuchartop3

//Are any women in the top 3 (binary)?//
gen bestwomanbinary=0
replace bestwomanbinary=1 if klobuchar>0
replace bestwomanbinary=1 if warren>0
replace bestwomanbinary=1 if harris>0

//Now turn to BLACK candidates//

replace booker=0 if booker==.

//Black candidate is top choice (binary)//
gen bestblack1=0
replace bestblack1=1 if harris==1
replace bestblack1=1 if booker==1

//Total number of black candidates in top 3//
gen bestbookertop3=0
replace bestbookertop3=1 if booker>0
gen bestblacktotal=bestbookertop3+bestharristop3

//Are there any black candidates in the top 3?//
gen bestblackbinary=0
replace bestblackbinary=1 if harris>0
replace bestblackbinary=1 if booker>0

//Now create CANDIDATE-SPECIFIC DVs//

//Make binary variables recording whether each candidate is in the #1 position//
gen biden1=0
replace biden1=1 if biden==1

gen sanders1=0
replace sanders1=1 if sanders==1

gen warren1=0
replace warren1=1 if warren==1

gen harris1=0
replace harris1=1 if harris==1

gen booker1=0
replace booker1=1 if booker==1

gen klobuchar1=0
replace klobuchar1=1 if klobuchar==1

gen buttigieg1=0
replace buttigieg1=1 if buttigieg==1

gen orourke1=0
replace orourke1=1 if orourke==1

//Create binary variables recording whether each candidate is in the top3//

rename bestharristop3 harristop3
rename bestwarrentop3 warrentop3
rename bestbookertop3 bookertop3
rename bestklobuchartop3 klobuchartop3

gen bidentop3=0
replace bidentop3=1 if biden>0

gen sanderstop3=0
replace sanderstop3=1 if sanders>0

gen buttigiegtop3=0
replace buttigiegtop3=1 if buttigieg>0

gen orourketop3=0
replace orourketop3=1 if orourke>0

**Generate dummy variables to indicate which subjects in the "strategic thinking" treatment**
**had high estimates of racism & sexism, and which had low estimates**

gen woman35=.
replace woman35=0 if stratcomp==1
replace woman35=1 if stratcomp==1 & notvotewoman>34
**The variable woman35 is coded 1 if the subjects said that 35% or more of swing-state voters would not vote**
**for a woman for president. I chose the number 35 because it is the median (the mean is slightly higher).**

gen woman15=. 
replace woman15=0 if stratcomp==1
replace woman15=1 if stratcomp==1 & notvotewoman>15

gen woman25=. 
replace woman25=0 if stratcomp==1
replace woman25=1 if stratcomp==1 & notvotewoman>24

**Same logic, for black candidates**

gen black35=.
replace black35=0 if stratcomp==1
replace black35=1 if notvoteblack>34 & stratcomp==1

gen black15=. 
replace black15=0 if stratcomp==1
replace black15=1 if stratcomp==1 & notvoteblack>15

gen black25=. 
replace black25=0 if stratcomp==1
replace black25=1 if stratcomp==1 & notvoteblack>24

**Code Subject Demographics**

gen male=0 if gender!="Male"
replace male=1 if gender=="Male"

gen female=0 if gender!="Female"
replace female=1 if gender=="Female"

gen white=0 
replace white=1 if race=="White / Caucasian" 

gen black=0
replace black=1 if race=="Black or African American"

gen api=0
replace api=1 if race=="Asian / Pacific Islander"

gen hispanic=0
replace hispanic=1 if race=="Hispanic or Latino"

gen other=0
replace other=1 if hispanic==0 & api==0 & black==0 & white==0

gen agegroup=1 if age=="18 - 24 years old"
replace agegroup=2 if age=="25 - 34 years old"
replace agegroup=3 if age=="35 - 44 years old"
replace agegroup=4 if age=="45 - 54 years old"
replace agegroup=5 if age=="55 - 64 years old"
replace agegroup=6 if age=="65 - 74 years old"
replace agegroup=7 if age=="75 years or older"

********************************************************************************
*********ANALYSIS*************************************************************
********************************************************************************

//for FIGURES 2.1 and 2.2//
**Candidate-specific ATEs**

ttest harris1, by(malecomp) welch
ttest harristop3, by(malecomp) welch
ttest warren1, by(malecomp) welch
ttest warrentop3, by(malecomp) welch
ttest biden1, by(malecomp) welch
ttest bidentop3, by(malecomp) welch
ttest sanders1, by(malecomp) welch
ttest sanderstop3, by(malecomp) welch
ttest orourke1, by(malecomp) welch
ttest orourketop3, by(malecomp) welch
ttest buttigieg1, by(malecomp) welch
ttest buttigiegtop3, by(malecomp) welch
ttest booker1, by(malecomp) welch
ttest bookertop3, by(malecomp) welch
ttest klobuchar1, by(malecomp) welch
ttest klobuchartop3, by(malecomp) welch

ttest harris1, by(whitecomp) welch
ttest harristop3, by(whitecomp) welch
ttest warren1, by(whitecomp) welch
ttest warrentop3, by(whitecomp) welch
ttest biden1, by(whitecomp) welch
ttest bidentop3, by(whitecomp) welch
ttest sanders1, by(whitecomp) welch
ttest sanderstop3, by(whitecomp) welch
ttest orourke1, by(whitecomp) welch
ttest orourketop3, by(whitecomp) welch
ttest buttigieg1, by(whitecomp) welch
ttest buttigiegtop3, by(whitecomp) welch
ttest booker1, by(whitecomp) welch
ttest bookertop3, by(whitecomp) welch
ttest klobuchar1, by(whitecomp) welch
ttest klobuchartop3, by(whitecomp) welch

//These results are also discussed in the accompanying section of the manuscript//

//That's all! Now use Illustrator to make the graphic.//
//To replicate the results of Study 3, see the do-file "Study3_Analysis.do" //

clear 
